package Leetcode;

public class Leetcode_189 {
    public static int findPoisonedDuration(int[] timeSeries, int duration) {
        int ans = 0;
        int expired = 0;
        for (int timeSery : timeSeries) {
            if (timeSery >= expired) {
                ans += duration;
            } else {
                ans += timeSery + duration - expired;
            }
            expired = timeSery + duration;
        }
        return ans;
    }

    public static void main(String[] args) {
        int[] timeSeries = {1,4};
        int duration = 2;
        System.out.println(findPoisonedDuration(timeSeries,duration));
    }
}
